import express from "express";
// import open from "open";
import { FilePaths, port, ServerUrls } from "./config";

const app = express();

const url = `http://localhost:${port}/JS/index.html`;
Object.entries(FilePaths).forEach(([path, resolvePath]) => {
  app.use(path, express.static(resolvePath));
});

app.get(ServerUrls.normalGet, (req, res) => {
  res.send("get 正常请求响应体");
});

app.get(ServerUrls.exceptionGet, (req, res) => {
  res.status(500).send("get 异常响应体!!!");
});

app.post(ServerUrls.normalPost, (req, res) => {
  res.send("post 正常请求响应体");
});

app.post(ServerUrls.exceptionPost, (req, res) => {
  res.status(500).send("post 异常响应体!!!");
});

app.post(ServerUrls.errorsUpload, (req, res) => {
  res.send("错误上报成功");
});

app.listen(port, () => {
  console.log("examples is available at " + url);
});
// open(url)